package io.gitee.twoke.generator.engine.impl.persistence;

import io.gitee.twoke.generator.engine.impl.cfg.GenerateEngineConfigurationImpl;
import io.gitee.twoke.generator.engine.impl.context.Context;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandContext;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandExecutor;
import io.gitee.twoke.generator.engine.impl.runtime.Clock;

public abstract class AbstractManager {
  
  protected GenerateEngineConfigurationImpl generateEngineConfiguration;
  
  public AbstractManager(GenerateEngineConfigurationImpl generateEngineConfiguration) {
    this.generateEngineConfiguration = generateEngineConfiguration;
  }
  
  // Command scoped 
  
  protected CommandContext getCommandContext() {
    return Context.getCommandContext();
  }
  protected Clock getClock() {
    return getGenerateEngineConfiguration().getClock();
  }
  protected <T> T getSession(Class<T> sessionClass) {
    return getCommandContext().getSession(sessionClass);
  }
  
  // Engine scoped
  
  protected GenerateEngineConfigurationImpl getGenerateEngineConfiguration() {
    return generateEngineConfiguration;
  }
  
  protected CommandExecutor getCommandExecutor() {
    return getGenerateEngineConfiguration().getCommandExecutor();
  }

}
